<template>
  <el-select
    v-model="selectData"
    allow-create
    default-first-option
    filterable
    :clearable="true"
    @change="periodChange"
    placeholder="请选择周期">
    <el-option v-for="it in periodList" :key="it" :label="it" :value="it"></el-option>
    </el-option>
  </el-select>
</template>

<script>
    import {examinPeriodList} from "@/api/dailyExamine/targetExamine/createAssessment"; //接口api
    export default {
        name: "",
        data(){
            return{
               selectData:'',
               periodList:[],
            }
        },
        created(){
           this.getPeriodData() ;
        },
        methods:{
            periodChange(){
                this.$emit('getDataByPerid',this.selectData)
            } ,
            // 获取考核周期数据
            getPeriodData() {
                examinPeriodList()
                    .then(r => {
                        if (r.data.code == 0) {
                           let periodArr = r.data.data;
                            periodArr = periodArr && periodArr.length>1 &&periodArr.reverse() ;
                            let items = periodArr.splice(0, 12) ;

                            this.periodList = items ;
                        }
                    })
                    .catch(err => {});
            },
            //清除选项
            resetVal(){
                this.selectData = '' ;
            }
        }
    }
</script>

<style scoped>

</style>
